home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / volume / VOLUMES4.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-27  |  8.4 KB  |  267 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Mabry Volume Sample"
  5.    ClientHeight    =   2760
  6.    ClientLeft      =   4755
  7.    ClientTop       =   2340
  8.    ClientWidth     =   3135
  9.    Height          =   3165
  10.    Left            =   4695
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   2760
  16.    ScaleWidth      =   3135
  17.    Top             =   1995
  18.    Width           =   3255
  19.    Begin VB.CommandButton Command2 
  20.       Caption         =   "Refresh"
  21.       Height          =   375
  22.       Left            =   840
  23.       TabIndex        =   6
  24.       Top             =   2280
  25.       Width           =   1335
  26.    End
  27.    Begin VB.Timer Timer1 
  28.       Enabled         =   0   'False
  29.       Interval        =   500
  30.       Left            =   120
  31.       Top             =   960
  32.    End
  33.    Begin VB.CommandButton Command1 
  34.       Caption         =   "Start Beeps"
  35.       Default         =   -1  'True
  36.       Height          =   375
  37.       Left            =   840
  38.       TabIndex        =   0
  39.       Top             =   1920
  40.       Width           =   1335
  41.    End
  42.    Begin VB.CheckBox chkLock 
  43.       Caption         =   "Lock Channels"
  44.       Height          =   255
  45.       Left            =   840
  46.       TabIndex        =   3
  47.       Top             =   1560
  48.       Width           =   1455
  49.    End
  50.    Begin VB.CheckBox chkMuteRight 
  51.       Caption         =   "Mute Right"
  52.       Height          =   255
  53.       Left            =   840
  54.       TabIndex        =   2
  55.       Top             =   1200
  56.       Width           =   1215
  57.    End
  58.    Begin VB.CheckBox chkMuteLeft 
  59.       Caption         =   "Mute Left"
  60.       Height          =   255
  61.       Left            =   840
  62.       TabIndex        =   1
  63.       Top             =   960
  64.       Width           =   1215
  65.    End
  66.    Begin VB.VScrollBar vscrRight 
  67.       Height          =   1815
  68.       Left            =   2760
  69.       Max             =   0
  70.       Min             =   32767
  71.       TabIndex        =   5
  72.       Top             =   240
  73.       Width           =   255
  74.    End
  75.    Begin VB.VScrollBar vscrLeft 
  76.       Height          =   1815
  77.       Left            =   2400
  78.       Max             =   0
  79.       Min             =   32767
  80.       TabIndex        =   4
  81.       Top             =   240
  82.       Width           =   255
  83.    End
  84.    Begin VolumeControl.MVolume MVolume1 
  85.       Left            =   120
  86.       Top             =   1440
  87.       _ExtentX        =   847
  88.       _ExtentY        =   847
  89.    End
  90.    Begin VB.Label Label6 
  91.       Alignment       =   2  'Center
  92.       Caption         =   "Min"
  93.       Height          =   255
  94.       Left            =   2400
  95.       TabIndex        =   12
  96.       Top             =   2160
  97.       Width           =   495
  98.    End
  99.    Begin VB.Label Label5 
  100.       Alignment       =   2  'Center
  101.       Caption         =   "Max"
  102.       Height          =   255
  103.       Left            =   2400
  104.       TabIndex        =   11
  105.       Top             =   0
  106.       Width           =   495
  107.    End
  108.    Begin VB.Label lblRight 
  109.       Height          =   255
  110.       Left            =   840
  111.       TabIndex        =   10
  112.       Top             =   480
  113.       Width           =   1335
  114.    End
  115.    Begin VB.Label lblLeft 
  116.       Height          =   255
  117.       Left            =   840
  118.       TabIndex        =   9
  119.       Top             =   120
  120.       Width           =   1335
  121.    End
  122.    Begin VB.Label Label2 
  123.       Alignment       =   1  'Right Justify
  124.       Caption         =   "Right:"
  125.       Height          =   255
  126.       Left            =   120
  127.       TabIndex        =   8
  128.       Top             =   480
  129.       Width           =   615
  130.    End
  131.    Begin VB.Label Label1 
  132.       Alignment       =   1  'Right Justify
  133.       Caption         =   "Left:"
  134.       Height          =   255
  135.       Left            =   120
  136.       TabIndex        =   7
  137.       Top             =   120
  138.       Width           =   615
  139.    End
  140. Attribute VB_Name = "Form1"
  141. Attribute VB_Creatable = False
  142. Attribute VB_Exposed = False
  143. Option Explicit
  144. Private fLocked As Boolean
  145. Private Sub chkLock_Click()
  146.     If chkLock.Value = vbChecked Then
  147.         fLocked = True
  148.     Else
  149.         fLocked = False
  150.     End If
  151. End Sub
  152. Private Sub chkMuteLeft_Click()
  153.     If chkMuteLeft.Value = vbChecked Then
  154.         MVolume1.MuteLeft = True
  155.     Else
  156.         'we are un-muting -- let's see if
  157.         'the user has messed with the volume
  158.         'from the system applet
  159.         MVolume1.MuteLeft = False
  160.         MVolume1.Refresh
  161.         vscrLeft.Value = MVolume1.VolumeLeft
  162.         vscrRight.Value = MVolume1.VolumeRight
  163.         lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  164.         lblRight.Caption = Hex$(MVolume1.VolumeRight)
  165.     End If
  166. End Sub
  167. Private Sub chkMuteRight_Click()
  168.     If chkMuteRight.Value = vbChecked Then
  169.         MVolume1.MuteRight = True
  170.     Else
  171.         'we are un-muting -- let's see if
  172.         'the user has messed with the volume
  173.         'from the system applet
  174.         MVolume1.MuteRight = False
  175.         MVolume1.Refresh
  176.         vscrLeft.Value = MVolume1.VolumeLeft
  177.         vscrRight.Value = MVolume1.VolumeRight
  178.         lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  179.         lblRight.Caption = Hex$(MVolume1.VolumeRight)
  180.     End If
  181. End Sub
  182. Private Sub Command1_Click()
  183.     If Timer1.Enabled = False Then
  184.         Timer1.Enabled = True
  185.         Command1.Caption = "Stop Beeps"
  186.     Else
  187.         Timer1.Enabled = False
  188.         Command1.Caption = "Start Beeps"
  189.     End If
  190. End Sub
  191. Private Sub Command2_Click()
  192.     'if you change the volume from the
  193.     'Windows Speaker applet, you can detect
  194.     'the change after invoking the Refresh
  195.     'method.
  196.     '
  197.     'Please note that the Volume control supports
  198.     'the full range of signed integer values (&H0000 thru &HFFFF)
  199.     'but the sample only supports &H0000 thru &H7FFF so the
  200.     'scrollbars could easily track the volume in a linear fashion.
  201.     'If you use the Windows volume applet to change the volume to
  202.     '&H8000 or above, an invalid property setting error will occur
  203.     'because this is outside of the range of the scroll bars.
  204.     '
  205.     'see the Form_Load event for details on trapping this in this
  206.     'sample. To use the entire range, extra code would be necessary
  207.     'to make the scroll bars behave in a linear fashion.
  208.     MVolume1.Refresh
  209.     vscrLeft.Value = MVolume1.VolumeLeft
  210.     vscrRight.Value = MVolume1.VolumeRight
  211.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  212.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  213. End Sub
  214. Private Sub Form_Load()
  215.      'the system and the Volume control tracks the volume levels
  216.     'using a range of &H0000 to &HFFFF. The sample uses
  217.     'Scrollbars to adjust the range in a linear fashion, but
  218.     'when the upper bit is set (ie -- above &H7FFF) the
  219.     'linear effect of the scrollbars is lost. So, although
  220.     'the control is capable of supporting the entire range of
  221.     '&H0 to &HFFFF, the sample only demonstrates a range of
  222.     '&H0 to &H7FFF so the Scrollbars could be easily used.
  223.     '
  224.     'The following statements trap values greater than &H7FFF
  225.     If MVolume1.VolumeLeft < 0 Then
  226.         MVolume1.VolumeLeft = &H7FFF
  227.     End If
  228.     If MVolume1.VolumeRight < 0 Then
  229.         MVolume1.VolumeRight = &H7FFF
  230.     End If
  231.     vscrLeft.Value = MVolume1.VolumeLeft
  232.     vscrRight.Value = MVolume1.VolumeRight
  233.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  234.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  235. End Sub
  236. Private Sub Timer1_Timer()
  237.     Beep
  238. End Sub
  239. Private Sub vscrLeft_Change()
  240.     MVolume1.VolumeLeft = vscrLeft.Value
  241.     If fLocked = True Then
  242.         vscrRight.Value = vscrLeft.Value
  243.     End If
  244.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  245. End Sub
  246. Private Sub vscrLeft_Scroll()
  247.     MVolume1.VolumeLeft = vscrLeft.Value
  248.     If fLocked = True Then
  249.         vscrRight.Value = vscrLeft.Value
  250.     End If
  251.     lblLeft.Caption = Hex$(MVolume1.VolumeLeft)
  252. End Sub
  253. Private Sub vscrRight_Change()
  254.     MVolume1.VolumeRight = vscrRight.Value
  255.     If fLocked = True Then
  256.         vscrLeft.Value = vscrRight.Value
  257.     End If
  258.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  259. End Sub
  260. Private Sub vscrRight_Scroll()
  261.     MVolume1.VolumeRight = vscrRight.Value
  262.     If fLocked = True Then
  263.         vscrLeft.Value = vscrRight.Value
  264.     End If
  265.     lblRight.Caption = Hex$(MVolume1.VolumeRight)
  266. End Sub
  267.